<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Form Layouts</title>

    <?php $this->load->view('library/header');?>
</head>
<body class="sticky-header">
<section>
    <?php $this->load->view('library/left');?>
    <!-- main content start-->
    <div class="main-content">
        <?php $this->load->view('library/top');?>
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                分类添加
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Forms</a>
                </li>
                <li class="active"> Forms Layouts</li>
            </ul>
        </div>
        <!-- page heading end-->
        <!--body wrapper start-->
        <section class="wrapper">
            <!-- page start-->
            <div class="row">
                <div class="col-lg-12">
                    <form id="commentForm" class="form-horizontal adminex-form" method="post">
                        <section class="panel">
                            <div class="panel-body">
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">分类名</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="cate_name" value="<?php echo $cate['cate_name'];?>" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">分类名</label>
                                    <div class="col-sm-10">
                                        <select name="pid" class="form-control">
                                            <option>选择分类</option>
                                            <?php foreach ($category as $k => $val) :?>
                                            <option value="<?php echo $val['cate_id'];?>">
                                                <?php echo $val['cate_id'] == $cate['pid'] ? 'selected' : '';?>
                                                ><?php echo str_repeat('--------', $val['level']).$val['cate_name'];?></option>
                                            <?php endforeach;?>
                                        </select>
                                    </div>
                                </div>
                                <input type="hidden" value="<?php echo $cate['cate_id'];?>" name="hidden_id">
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"></label>
                                    <div class="col-lg-10">
                                        <button type="submit" class="btn btn-primary">Submit</button>
                                    </div>
                                </div>
                            </div>
                        </section>
                    </form>
                </div>
            </div>
        </section>
        <footer>
            2014 &copy; AdminEx by
        </footer>
    </div>
</section>
<?php $this->load->view('library/footer');?>
<script>
    $(function () {
        $('.btn-primary').click(function () {
            var tags_name = $("input[name='cate_name']").val();
            var pid = $("select[name='pid']").val();
            var hidden_id = $("input[name='hidden_id']").val();
            $.ajax({
                type: 'POST',
                url: "<?php echo base_url('Siteweb/cat_add');?>",
                data: {
                    tags_name: tags_name,
                    pid: pid,
                    hidden_id: hidden_id
                },
                // success: function (data) {
                //     if (data.status == 'success') {
                //         window.location.href = "<?php echo base_url('Siteweb/cat_list');?>";
                //     }
                // },
            });
        })


        // $('#commentForm').submit(function () {

        //     t = setTimeout(function() {
        //         $('.btn-primary').attr('disabled','disabled');
        //     }, 200);


        //     var data = new FormData(this);

        //     $.ajax({
        //         type: 'POST',
        //         url: '<?php echo base_url('siteweb/tags_add'. ($size ? "/id/{$size['size_id']}" : ''));?>',
        //         data: data,
        //         success: function (data) {
        //             clearTimeout(t);
        //             if (data.status != 'success') {
        //                 swal({
        //                     title: data.info,
        //                     text: '2秒后关闭',
        //                     type: data.status,
        //                     allowOutsideClick: false,
        //                     timer: 1500,
        //                     showConfirmButton: false
        //                 });
        //                 $('.btn-primary').attr("disabled",false);
        //             } else {
        //                 swal({
        //                     title: data.info,
        //                     text: '2秒后关闭',
        //                     type: data.status,
        //                     allowOutsideClick: false,
        //                     timer: data.stop ? data.stop : 1500,
        //                     showConfirmButton: false
        //                 }).then(function(isConfirm) {
        //                     window.onbeforeunload = '';
        //                     window.location.href = '<?php echo base_url('siteweb/size_list');?>';
        //                 });
        //                 $('.btn-primary').removeClass('btn-submit-disabled').html(data.info);
        //             }

        //         },
        //         dataType:'json',
        //         cache: false,
        //         contentType: false,
        //         processData: false
        //     });

        //     return false;
        // });

    });
</script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>